<template>
	<view class="content">

		<u-empty mode="data" icon="../../static/images/not-data.png" text="暂无数据" v-if="list.length==0">
		</u-empty>
		<view v-else class="list-group">
			<view v-for="(item,index) in list" :key="item.id" class="list-item" @click="handleClick(item)">
				<view style="display: flex;justify-content: space-between;font-size: 28rpx;margin-bottom: 20rpx;">
					<view style="display: flex;align-items: center;">

						<view>{{item.empname}} ({{item.orgName}})</view>
					</view>
					<view style="color: #999;font-size: 24rpx;">{{item.duty}}

					</view>
				</view>
				<view style="font-size: 28rpx;margin-bottom: 30rpx;">
					<u-row justify="space-between" customStyle="margin-top: 10px">
						<u-col span="8">
							<view style="display: flex;align-items: center;">
								<view style="color: #999999;">当前评分：</view>
								<view>{{item.finalScore}}
									<span style="color: #f56c6c;margin-left: 10px;"
										v-if="item.assessmentGrade">({{item.assessmentGrade}})</span>
								</view>
							</view>
						</u-col>
						<u-col span="4">
							<view style="display: flex;align-items: center;justify-content: flex-end;">
								<view v-if="item.beforeSumStatus==0"><u-tag text="已提交" plain plainFill
										borderColor="#ecf5ff"> </u-tag></view>
								<view v-if="item.beforeSumStatus==1">
									<u-tag text="未提交" type="error" plain plainFill borderColor="#ecf5ff"> </u-tag>
								</view>

							</view>
						</u-col>
					</u-row>
				</view>
				<u-line></u-line>
			</view>
		</view>
		<u-tabbar :placeholder="true" :safeAreaInsetBottom="false">
			<view
				style="display: flex;align-items: center;justify-content: space-between;padding: 0 30rpx;width: 100%;">
				<view style="display: flex;align-items: center;">
					<view style="margin-right: 10px;">共 {{list.length}} 条数据</view>
				</view>
				<view v-if="status!=2">
					<u-button style="margin-right: 20rpx;height: 60rpx;" type="primary"
						@click="()=>show = true">一键审核</u-button>
				</view>
				<view v-else>
					
					<u-button style="margin-right: 20rpx;height: 60rpx;" type="primary"
						disabled>审核完毕</u-button>
				</view>
			</view>
		</u-tabbar>
		<u-modal :show="show" title="提示" @confirm="handleConfirm" showCancelButton @cancel="()=>show =false">
			是否一键审核?
		</u-modal>
	</view>
</template>

<script>
	import {
		GetEmployeeViewDetails,
		PostoneClickReview
	} from '@/api/main'
	export default {
		data() {
			return {
				summaryId: null,
				list: [],
				show: false,
				status:1
			}
		},
		onLoad(options) {
			this.summaryId = options.id
			this.status = options.status
		},
		onShow() {
			this.getData()
		},
		methods: {
			getData() {
				let fromdata = new FormData()
				fromdata.append('summaryId', this.summaryId)
				GetEmployeeViewDetails(fromdata).then(response => {
					console.log(response)
					this.list = response.data
				})
			},
			handleClick(item) {
				if (item.beforeSumStatus == 0) {
					if(this.status==2){
						uni.navigateTo({
							url: `/pages/todo-list/index/agency-details?id=${item.id}&source=1`
						})
					}else {
						uni.navigateTo({
							url: `/pages/todo-list/index/agency-details?id=${item.id}&source=2`
						})
					}
					
				} else {
					uni.showToast({
						icon: "none",
						title: "未提交用户不可重新打分"
					})
				}

			},
			handleConfirm() {
				let formdata  = new FormData()
				formdata.append("summaryId",this.summaryId)
				PostoneClickReview(formdata).then((response) => {
					if (response.code == 200) {
						uni.showToast({
							icon: "none",
							title: response.msg
						})

						this.show = false
						setTimeout(() => {
							uni.navigateBack({
								delta: 1
							})
						}, 1000)
					} else {
						uni.showToast({
							icon: "none",
							title: response.msg
						})
					}
				});
			}

		}
	}
</script>
<style scoped lang="scss">
	.list-group {
		padding: 20rpx;

		.list-item {
			padding: 30rpx 30rpx;
			padding-bottom: 0;

			.status {
				color: #008B8B;
				font-weight: 400;
			}

			.actions {
				background: #2db7f5;
				color: #ffffff;
				padding: 4rpx 18rpx;
				border-radius: 5rpx;
				font-size: 26rpx;
			}
		}
	}
</style>